//
// Decompiled with: Decompiler.NET, Version=1.3.1.18439, Culture=neutral, PublicKeyToken=null, Version: 1.3.1.18439
// Decompilation Started at: 3/15/2009 10:34:26 PM
// Copyright 2003 - 2004, Jungle Creatures, Inc., All Rights Reserved. 
// Written by Jonathan Pierce, Email: support@junglecreatures.com
//

namespace PatientManagement

{
		
		#region Namespace Import Declarations
		
			using System.ComponentModel;
			using System.Data.SqlClient;
			using System.Drawing;
			using System;
			using System.Resources;
			using System.Windows.Forms;
			
		#endregion
		
	public class frmCapNhatQuyen : Form
	
	{
		
		#region Fields
			private Button btExit;
			private Button btSave;
			private Button btSearch;
			private Button btXoa;
			private ComboBox cbQuyen;
			private Container components;
			private string connStr;
			public int flag;
			private GroupBox groupBox1;
			private Label label1;
			private Label label2;
			private Label label3;
			private TextBox tbUserName;
		#endregion
		
		#region Constructors
		
			public frmCapNhatQuyen ()
			
			{
				this.components = ((System.ComponentModel.Container) null);
				this.flag = 1;
				this.InitializeComponent ();
				this.connStr = Connection.ConnectionString ();
				return;
			}
			
		#endregion
		
		#region Methods
		
			private void btExit_Click (object sender, EventArgs e)
			
			{
				base.Close ();
				return;
			}
			
			private void btSave_Click (object sender, EventArgs e)
			
			{
				int i;
				SqlConnection theSqlConnection;
				string theString;
				SqlCommand theSqlCommand;
				object[] theObjectArray;
				if (this.cbQuyen.Text != "")
				{
					goto L_002F;
				}
				DialogResult theDialogResult = MessageBox.Show ("Vui l?ng ch?n quy?n!", "L?i nh?p", MessageBoxButtons.OK, MessageBoxIcon.Hand);
				goto L_0156;
				
			L_002F:
				
				{
				}
				if (this.cbQuyen.Text != "Tr??ng Ph?ng Kh?m")
				{
					goto L_004A;
				}
				i = 0;
				goto L_0082;
				
			L_004A:
				
				{
				}
				if (this.cbQuyen.Text != "B?c S?")
				{
					goto L_0065;
				}
				i = 1;
				goto L_0082;
				
			L_0065:
				
				{
				}
				if (this.cbQuyen.Text != "Y T?")
				{
					goto L_0080;
				}
				i = 2;
				goto L_0082;
				
			L_0080:
				
				{
				}
				i = 3;
				
			L_0082:
				
				{
				}
				theSqlConnection = new SqlConnection (this.connStr);
				theObjectArray = new object[5];
				theObjectArray[0] = "UPDATE Users SET usrRole=";
				theObjectArray[1] = i;
				theObjectArray[2] = " WHERE usrName=\'";
				theObjectArray[3] = this.tbUserName.Text;
				theObjectArray[4] = "\'";
				theString = string.Concat (theObjectArray);
				theSqlCommand = new SqlCommand (theString, theSqlConnection);
				theSqlCommand.Connection.Open ();
				int i2 = theSqlCommand.ExecuteNonQuery ();
				theSqlCommand.Connection.Close ();
				DialogResult theDialogResult2 = MessageBox.Show ("C?p nh?t th?nh c?ng!", "C?p nh?t th?nh c?ng!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
				this.tbUserName.Text = "";
				this.tbUserName.Enabled = true;
				this.btSearch.Enabled = true;
				this.btSave.Enabled = false;
				this.btXoa.Enabled = false;
				bool theBoolean = this.tbUserName.Focus ();
				
			L_0156:
				return;
			}
			
			private void btSearch_Click (object sender, EventArgs e)
			
			{
				int i;
				string theString;
				SqlConnection theSqlConnection;
				SqlCommand theSqlCommand;
				SqlDataReader theSqlDataReader;
				i = 0;
				if (this.tbUserName.Text != "")
				{
					goto L_0031;
				}
				DialogResult theDialogResult = MessageBox.Show ("Vui l?ng nh?p t?n ??ng nh?p!", "L?i nh?p!", MessageBoxButtons.OK, MessageBoxIcon.Hand);
				goto L_0128;
				
			L_0031:
				
				{
				}
				theString = string.Concat ("SELECT * FROM Users WHERE usrName=\'", this.tbUserName.Text, "\'");
				theSqlConnection = new SqlConnection (this.connStr);
				theSqlCommand = new SqlCommand (theString, theSqlConnection);
				theSqlCommand.Connection.Open ();
				theSqlDataReader = theSqlCommand.ExecuteReader ();
				goto L_0079;
				
			L_0075:
				
				{
				}
				i++;
				
			L_0079:
				
				{
				}
				if (theSqlDataReader.Read ())
				{
					goto L_0075;
				}
				if (i <= 0)
				{
					goto L_00E2;
				}
				if (MessageBox.Show (string.Concat ("T?n truy nh?p: ", this.tbUserName.Text, " ???c t?m th?y.\n B?n c? mu?n thay ??i quy?n cho user n?y kh?ng?"), "Thay ??i quy?n!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
				{
					goto L_00E0;
				}
				this.tbUserName.Enabled = false;
				this.btSave.Enabled = true;
				this.btXoa.Enabled = true;
				this.btSearch.Enabled = false;
				
			L_00E0:
				
				{
				}
				goto L_0122;
				
			L_00E2:
				
				{
				}
				this.btSave.Enabled = false;
				this.btXoa.Enabled = false;
				DialogResult theDialogResult2 = MessageBox.Show (string.Concat ("T?n truy nh?p: \'", this.tbUserName.Text, "\' kh?ng t?n t?i!"), "L?i nh?p", MessageBoxButtons.OK, MessageBoxIcon.Hand);
				
			L_0122:
				
				{
				}
				theSqlConnection.Close ();
				
			L_0128:
				return;
			}
			
			private void btXoa_Click (object sender, EventArgs e)
			
			{
				SqlConnection theSqlConnection;
				SqlCommand theSqlCommand;
				if (MessageBox.Show (string.Concat ("C? ph?i b?n mu?n x?a quy?n truy nh?p: \'", this.tbUserName.Text.ToString (), "\' n?y kh?ng?"), "X?a Quy?n Truy Nh?p", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
				{
					goto L_00DB;
				}
				theSqlConnection = new SqlConnection (this.connStr);
				theSqlCommand = new SqlCommand (string.Concat ("DELETE Users WHERE usrName=\'", this.tbUserName.Text, "\'"), theSqlConnection);
				theSqlCommand.Connection.Open ();
				int i = theSqlCommand.ExecuteNonQuery ();
				theSqlCommand.Connection.Close ();
				DialogResult theDialogResult = MessageBox.Show ("Quy?n truy nh?p ?? ???c x?a!", "Xo? Quy?n Truy Nh?p!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
				this.tbUserName.Text = "";
				this.tbUserName.Enabled = true;
				this.btSearch.Enabled = true;
				this.btSave.Enabled = false;
				this.btXoa.Enabled = false;
				bool theBoolean = this.tbUserName.Focus ();
				
			L_00DB:
				return;
			}
			
			protected override void Dispose (bool disposing)
			
			{
				this.flag = 0;
				if (! disposing)
				{
					goto L_001D;
				}
				if (this.components == null)
				{
					goto L_001D;
				}
				this.components.Dispose ();
				
			L_001D:
				
				{
				}
				base.Dispose (disposing);
				return;
			}
			
			private void InitializeComponent ()
			
			{
				ResourceManager theResourceManager;
				object[] theObjectArray;
				Control[] theControlArray;
				Control[] theControlArray2;
				theResourceManager = new ResourceManager (typeof (frmCapNhatQuyen));
				this.label1 = new Label ();
				this.btExit = new Button ();
				this.btSave = new Button ();
				this.btSearch = new Button ();
				this.tbUserName = new TextBox ();
				this.label3 = new Label ();
				this.label2 = new Label ();
				this.cbQuyen = new ComboBox ();
				this.btXoa = new Button ();
				this.groupBox1 = new GroupBox ();
				this.groupBox1.SuspendLayout ();
				base.SuspendLayout ();
				this.label1.Font = new System.Drawing.Font ("Verdana", 12F, FontStyle.Bold, GraphicsUnit.Point, ((byte) byte.MinValue));
				this.label1.ForeColor = Color.MediumBlue;
				this.label1.Location = new Point (80, 16);
				this.label1.Name = "label1";
				this.label1.Size = new System.Drawing.Size (256, 23);
				this.label1.TabIndex = 0;
				this.label1.Text = "C?p Nh?t Quy?n Truy Nh?p";
				this.btExit.FlatStyle = FlatStyle.Popup;
				this.btExit.Location = new Point (200, 16);
				this.btExit.Name = "btExit";
				this.btExit.Size = new System.Drawing.Size (80, 23);
				this.btExit.TabIndex = 5;
				this.btExit.Text = "Tho?t";
				this.btExit.Click += new EventHandler (this.btExit_Click);
				this.btSave.Enabled = false;
				this.btSave.FlatStyle = FlatStyle.Popup;
				this.btSave.Location = new Point (8, 16);
				this.btSave.Name = "btSave";
				this.btSave.Size = new System.Drawing.Size (96, 23);
				this.btSave.TabIndex = 3;
				this.btSave.Text = "C?p Nh?t";
				this.btSave.Click += new EventHandler (this.btSave_Click);
				this.btSearch.FlatStyle = FlatStyle.Popup;
				this.btSearch.Location = new Point (320, 64);
				this.btSearch.Name = "btSearch";
				this.btSearch.TabIndex = 1;
				this.btSearch.Text = "T?m";
				this.btSearch.Click += new EventHandler (this.btSearch_Click);
				this.tbUserName.BorderStyle = BorderStyle.FixedSingle;
				this.tbUserName.Location = new Point (152, 64);
				this.tbUserName.Name = "tbUserName";
				this.tbUserName.Size = new System.Drawing.Size (160, 23);
				this.tbUserName.TabIndex = 0;
				this.tbUserName.Text = "";
				this.tbUserName.KeyPress += new KeyPressEventHandler (this.tbUserName_KeyPress);
				this.label3.Location = new Point (24, 96);
				this.label3.Name = "label3";
				this.label3.Size = new System.Drawing.Size (136, 23);
				this.label3.TabIndex = 11;
				this.label3.Text = "Quy?n truy nh?p:";
				this.label2.Location = new Point (24, 64);
				this.label2.Name = "label2";
				this.label2.Size = new System.Drawing.Size (120, 23);
				this.label2.TabIndex = 10;
				this.label2.Text = "T?n truy nh?p:";
				this.cbQuyen.DropDownStyle = ComboBoxStyle.DropDownList;
				theObjectArray = new object[4];
				theObjectArray[0] = "Tr??ng Ph?ng Kh?m";
				theObjectArray[1] = "B?c S?";
				theObjectArray[2] = "Y T?";
				theObjectArray[3] = "D??c S?";
				this.cbQuyen.Items.AddRange (theObjectArray);
				this.cbQuyen.Location = new Point (152, 96);
				this.cbQuyen.Name = "cbQuyen";
				this.cbQuyen.Size = new System.Drawing.Size (160, 24);
				this.cbQuyen.TabIndex = 2;
				this.btXoa.Enabled = false;
				this.btXoa.FlatStyle = FlatStyle.Popup;
				this.btXoa.Location = new Point (112, 16);
				this.btXoa.Name = "btXoa";
				this.btXoa.Size = new System.Drawing.Size (80, 23);
				this.btXoa.TabIndex = 4;
				this.btXoa.Text = "Xo?";
				this.btXoa.Click += new EventHandler (this.btXoa_Click);
				theControlArray = new Control[3];
				theControlArray[0] = ((Control) this.btSave);
				theControlArray[1] = ((Control) this.btXoa);
				theControlArray[2] = ((Control) this.btExit);
				this.groupBox1.Controls.AddRange (theControlArray);
				this.groupBox1.Location = new Point (24, 120);
				this.groupBox1.Name = "groupBox1";
				this.groupBox1.Size = new System.Drawing.Size (288, 48);
				this.groupBox1.TabIndex = 20;
				this.groupBox1.TabStop = false;
				this.AutoScaleBaseSize = new System.Drawing.Size (7, 16);
				base.ClientSize = new System.Drawing.Size (414, 187);
				theControlArray2 = new Control[7];
				theControlArray2[0] = ((Control) this.groupBox1);
				theControlArray2[1] = ((Control) this.cbQuyen);
				theControlArray2[2] = ((Control) this.btSearch);
				theControlArray2[3] = ((Control) this.tbUserName);
				theControlArray2[4] = ((Control) this.label3);
				theControlArray2[5] = ((Control) this.label2);
				theControlArray2[6] = ((Control) this.label1);
				base.Controls.AddRange (theControlArray2);
				this.Font = new System.Drawing.Font ("Verdana", 9.75F, FontStyle.Regular, GraphicsUnit.Point, ((byte) byte.MinValue));
				base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
				base.Icon = ((System.Drawing.Icon) theResourceManager.GetObject ("$this.Icon"));
				base.MaximizeBox = false;
				base.MinimizeBox = false;
				base.Name = "frmCapNhatQuyen";
				base.StartPosition = FormStartPosition.CenterScreen;
				this.Text = "C?p Nh?t Quy?n Truy Nh?p";
				this.groupBox1.ResumeLayout (false);
				base.ResumeLayout (false);
				return;
			}
			
			private void tbUserName_KeyPress (object sender, KeyPressEventArgs e)
			
			{
				if (e.KeyChar != '\r')
				{
					goto L_0012;
				}
				this.btSearch_Click (sender, ((EventArgs) e));
				
			L_0012:
				return;
			}
			
		#endregion
	}
	
}

